<template>
  <el-form-item label="相关链接">
    <el-button type="primary" icon="plus" @click="handleAdd" style="margin-bottom: 15px">添加</el-button>
    <el-table :data="modelValue" border>
      <el-table-column label="答案选项">
        <template #default="scope">
          <el-input v-model="scope.row.answer" placeholder="请输入地址"></el-input>
        </template>
      </el-table-column>
      <el-table-column label="正确答案" width="100px">
        <template #default="scope">
          <el-select v-model="scope.row.isYes" placeholder="名称">
            <el-option label="是" :value="true"></el-option>
            <el-option label="否" :value="false"></el-option>
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="操作" width="150px">
        <template #default="scope">
          <el-button link type="primary" icon="delete" @click="modelValue.splice(scope.$index, 1)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </el-form-item>
</template>
<script setup>
const props = defineProps({
  modelValue: { type: Array, default: () => [] },
})

// 新增
function handleAdd() {
  props.modelValue.push({})
}
</script>
<style lang="scss" scoped></style>
